//*******************************************************************
//	created:	26:4:2011   9:59
//	filename: 	PreInclude.h
//	author:		tiamo
//	purpose:	pre include
//*******************************************************************

#pragma once

#ifdef WIN32
	#include <sdkddkver.h>
#endif

#include <cstdint>
#include <cstdio>
#include <clocale>
#include <cstring>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <queue>
#include <exception>
#include <memory>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <atomic>

typedef std::string															AnsiString;
typedef std::wstring														UniString;
typedef std::string															Utf8String;

#ifdef WIN32
	#include <process.h>
	#include <ws2tcpip.h>
	#include <tchar.h>
#else
	#include <wctype.h>
	#include <fcntl.h>
	#include <pthread.h>
	#include <syslog.h>
	#include <signal.h>
	#include <sys/select.h>
	#include <sys/epoll.h>
	#include <sys/time.h> 
	#include <netinet/in.h>
	#include <arpa/inet.h> 
	#include <netdb.h>
	typedef unsigned int													SOCKET;
	#define INVALID_SOCKET													(SOCKET)(~0)
	#define ARRAYSIZE(a)													(sizeof((a))/ sizeof((a)[0]))
#endif

#ifdef min
	#undef min
#endif

#ifdef max
	#undef max
#endif

#include <zlib.h>
#include <openssl/rc4.h>
#include <openssl/rsa.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/ssl.h>
#include <openssl/objects.h>
#include <curl/curl.h>
#include <mysql/mysql.h>
#include <libxml/xmlstring.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/HTMLparser.h>

#include "stringhelper.h"
#include "exceptionhelper.h"
#include "platformhelper.h"
#include "synchelper.h"
#include "smartpointer.h"
#include "lockedqueue.h"
#include "requestmanager.h"
#include "timermanager.h"
#include "databuffer.h"
#include "stdiofile.h"
#include "logmanager.h"
#include "base64helper.h"
#include "zlibhelper.h"
#include "xmlparser.h"
#include "xmlrpcexception.h"
#include "xmlrpcvalue.h"
#include "config.h"
#include "httprequest.h"
#include "mysqlstatement.h"
#include "mysqldatabase.h"
#include "sqlrequest.h"
#include "addresshelper.h"
#include "asyncsocket.h"
#include "sslsocket.h"
#include "socketmanager.h"
#include "selectsocketmanager.h"
#include "epollsocketmanager.h"
#include "service.h"
#include "apnservice.h"
#include "rssservice.h"
#include "server.h"

#define LogDebug(f, ...)													Server::getSingleton()->getLogManager()->logMessage(utils::LogManager::LevelDebug, (f), __VA_ARGS__)
#define LogInfo(f, ...)														Server::getSingleton()->getLogManager()->logMessage(utils::LogManager::LevelInfo, (f), __VA_ARGS__)
#define LogWarning(f, ...)													Server::getSingleton()->getLogManager()->logMessage(utils::LogManager::LevelWarning, (f), __VA_ARGS__)
#define LogError(f, ...)													Server::getSingleton()->getLogManager()->logMessage(utils::LogManager::LevelError, (f), __VA_ARGS__)
#define CAT_A_B(a, b)														a##b
#define CAT_A_B_2(a, b)														CAT_A_B(a, b)
#define ON_BLOCK_EXIT														auto CAT_A_B_2(__resourceHelper, __LINE__) = utils::makeResourceHelper

#ifdef WIN32
	#pragma comment(lib, "ws2_32")
	#pragma comment(lib, "libeay32")
	#pragma comment(lib, "ssleay32")
	#pragma comment(lib, "zdll")
	#pragma comment(lib, "libxml2")
	#pragma comment(lib, "libmysql")
#endif
